﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace TMIS
{
    public partial class frmReviewOpinion : frmCommon
    {
        private Guid guid;
        private BLL.ReviewOpinion bll = new BLL.ReviewOpinion();
        public frmReviewOpinion()
        {
            InitializeComponent();
        }
        public frmReviewOpinion(Guid guid)
        {
            this.guid = guid;
            InitializeComponent();
            this.FillComponent();
        }
        /// <summary>
        /// 窗体控件数据初始化
        /// </summary>
        private void FillComponent()
        {
            Model.ReviewOpinion re = bll.Get(this.guid);
            txtTopic.Text = re.Topic.ToString();
            txtSurvey.Text = re.Survey.ToString();
            txtDemonstrate.Text = re.Demonstrate.ToString();
            txtQuality.Text = re.Quality.ToString();
            txtInnovation.Text = re.Innovation.ToString();
            txtTotal.Text = re.TotalScore.ToString();
            this.Priview();
        }
        public override void Save()
        {
            txtTotal.Text = (Convert.ToInt16(txtTopic.Text) + Convert.ToInt16(txtSurvey.Text) + Convert.ToInt16(txtDemonstrate.Text) + Convert.ToInt16(txtQuality.Text) + Convert.ToInt16(txtInnovation.Text)).ToString();
            Model.ReviewOpinion reivewopinion = new Model.ReviewOpinion()
            {
                ID = this.guid,
                Topic = Convert.ToInt16(txtTopic.Text),
                Survey = Convert.ToInt16(txtSurvey.Text),
                Demonstrate = Convert.ToInt16(txtDemonstrate.Text),
                Quality = Convert.ToInt16(txtQuality.Text),
                Innovation = Convert.ToInt16(txtInnovation.Text),
                TotalScore=Convert.ToInt16(txtTotal.Text)
            };
            bll.Update(reivewopinion);

        }

        public override void Priview()
        {
            this.reviewOpinionTableAdapter.FillByStudentID(this.reportDS.ReviewOpinion, guid);
            this.reportViewer.RefreshReport();
        }

    }
}
